package com.changsideal.tool;

import com.changsideal.excel.annotation.Column;

import java.lang.reflect.Field;
import java.util.Comparator;

/**
 * @ClassName ExcelOrderCompare
 * @Description TODO
 * @Author Create by Chansideal.Haosc
 * @Date 2019/7/10 9:38
 * @Version 1.0
 **/
public class ExcelOrderCompare implements Comparator<Field> {

    @Override
    public int compare(Field o1, Field o2) {
        Column annotation1 = o1.getAnnotation(Column.class);
        Column annotation2 = o2.getAnnotation(Column.class);
        if (annotation1.sqlOrder() > annotation2.sqlOrder()) {
            return 1;
        } else {
            return -1;
        }
    }
}
